﻿using System;
using System.Collections.Generic;
using System.Text;

namespace mssql_password
{
    public class BinWriter
    {
        internal List<byte> bytes { get; set; }

        public BinWriter()
        {
            bytes = new List<byte>();
        }

        public void Write(byte b)
        {
            bytes.Add(b);
        }

        public void WriteHexString(string s)
        {
            var reader = new BinReader(s);
            for (int i = 0; i < reader.Length; i++)
            {
                bytes.Add(reader.ReadByte());
            }
        }
        public void WriteUnicodeText(string s)
        {
            bytes.AddRange(Encoding.Unicode.GetBytes(s));
        }

        public byte[] ToArray()
        {
            return bytes.ToArray();
        }
    }
}
